package com.emergency.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.emergency.data.entity.Village;
import com.emergency.data.vo.VillageVO;
import com.emergency.mapper.VillageMapper;
import com.emergency.service.VillageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * (Village)村社区服务实现类
 *
 * @author makejava
 * @since 2020-09-17
 */
@Service
public class VillageServiceImpl extends ServiceImpl<VillageMapper, Village> implements VillageService {

    @Resource
    private VillageMapper villageMapper;

    @Override
    public List<VillageVO> getVillageList() {
        return villageMapper.selectList(null).stream().map(c -> {
            VillageVO vo = new VillageVO();
            BeanUtil.copyProperties(c, vo);
            return vo;
        }).collect(Collectors.toList());
    }
}
